Skip to content

Extract Root and Shizuku command execution - #9

Merged
Dhangofa merged 10 commits into
mainfrom
dev
Aug 11, 2026
Merged

Extract Root and Shizuku command execution#9
Dhangofa merged 10 commits into
mainfrom
dev

Conversation

@Dhangofa

Copy link
Copy Markdown
Owner

Summary

This PR completes Phase 2 of the NetToggle modular refactor by moving Root and Shizuku shell execution out of NetworkTileService into dedicated command modules.

The refactor preserves the existing network-switching behavior while introducing structured command results for future error reporting.

New Command Modules

  • Added CommandExecutor as the shared execution interface.
  • Added RootCommandExecutor for commands executed through su.
  • Added ShizukuCommandExecutor for commands executed through Shizuku.
  • Added CommandExecutorFactory to select the appropriate executor from the saved execution mode.
  • Added ProcessResultReader to collect process results.
  • Added StreamCollector to read stdout and stderr concurrently.
  • Added CommandResult to store:
    • executed command
    • exit code
    • stdout
    • stderr
    • exception details
    • success state

NetworkTileService Changes

  • Removed direct Root process execution.
  • Removed direct Shizuku process execution and reflection handling.
  • Removed the local CommandResult implementation.
  • Removed duplicated process stream-reading logic.
  • Routed commands through CommandExecutorFactory.
  • Updated readback and apply operations to use the shared CommandResult model.
  • Preserved existing SIM resolution and network mode behavior.

Reliability Improvements

  • stdout and stderr are now consumed concurrently while commands run.
  • Command failures retain structured diagnostic information instead of returning only a boolean.
  • Root and Shizuku now use the same result contract.
  • The command layer is ready for the planned copyable error-reporting interface.

Behavior Preserved

  • Root execution mode

  • Shizuku execution mode

  • Auto Target SIM detection

  • Manual SIM 1 and SIM 2 selection

  • Subscription-ID based network mode readback

  • Physical-slot based network mode application

  • Cached Quick Settings tile state

  • Existing tile labels and icons

  • Existing mode cycle:

    4G Only → 5G Only → Preferred 5G → Preferred 4G

- Removed direct Root and Shizuku command execution from NetworkTileService.
- Removed the local CommandResult implementation and legacy stream-reading methods.
- Routed shell commands through CommandExecutorFactory based on the selected execution mode.
- Updated command handling to use the shared CommandResult model.
- Updated command result access to use exit code, stdout, and success getters.
- Preserved existing network mode readback, SIM resolution, tile state, and switching behavior.
- Corrected the broken newline character literal in StreamCollector.
- Restored valid Java syntax for appending captured process output.
- Fixes the Phase 2 release compilation failure.
@Dhangofa
Dhangofa merged commit 6b6dcb3 into main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant